package choose.student1;


import java.util.Random;

public class Choose {
    public static void main(String[] args) {
        Class class7=new Class(7,4);
        Class class8=new Class(8,4);
        Group group1=new Group(1,"吴彦组",class7);
        Group group2=new Group(2,"人民当家做组", class7);
        Group group3=new Group(3,"活着就知组", class8);
        Group group4=new Group(4,"风雨无组", class8);
        class7.addgroup(group1);
        class7.addgroup(group2);
        class8.addgroup(group3);
        class8.addgroup(group4);
        Student student1=new Student("小红",202301, group1);
        Student student2=new Student("李明",202302, group1);
        Student student3=new Student("王五",202303, group2);
        Student student4=new Student("小兰",202304, group2);
        Student student5=new Student("小李",202305, group3);
        Student student6=new Student("小赵",202306, group3);
        Student student7=new Student("小刘",202307, group4);
        Student student8=new Student("小芳",202308, group4);
        group1.addstudent(student1);
        group1.addstudent(student2);
        group2.addstudent(student3);
        group2.addstudent(student4);
        group3.addstudent(student5);
        group3.addstudent(student6);
        group4.addstudent(student7);
        group4.addstudent(student8);
        Random random=new Random();

        Class[] classes={class7,class8};
        int classindex= random.nextInt(classes.length);
        Class chosenclass=classes[classindex];
        int groupindex= random.nextInt(chosenclass.getTotalgroups().length);
        Group chosengroup=chosenclass.getTotalgroups()[groupindex];
        int studentindex= random.nextInt(chosengroup.getStudents().length);
        Student chosenstudent=chosengroup.getStudents()[studentindex];
        //随机抽取小组
        System.out.println("抽到的小组是第"+chosengroup.getGroupid()+"组:"+chosengroup.getGroupname());
        //随机抽取小组中的学生 
        System.out.println("抽到的学生是："+chosenstudent.getName());
        //随机抽取班级中的学生
        System.out.println("抽到的学生是："+chosenclass.getClassnum()+"班 "+chosenstudent.getStudentid()+' '+chosenstudent.getName());
    }
}
